//  Copyright (c) 2010 Mahesh Sharma,Matt MacDonald
//
//  Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.

package org.prx.prp.view;

import org.prx.prp.R;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;


	public class MyView extends FrameLayout {
		int count;
	    public MyView(Context c, String label,int count) {
	        super(c);	        
	        ImageView iv = new ImageView(c);
	        this.count=count;
	        LayoutParams p=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
	        iv.setLayoutParams(p);	        	        
	        Drawable f=getResources().getDrawable(R.drawable.tab_selector);  
	        
	        TextView tv = new TextView(c);
	        iv.setImageDrawable(f);
	        tv.setText(label);
	        tv.setGravity(Gravity.CENTER);
	        tv.setTextSize(18);
	        tv.setTextColor(Color.argb(220, 255, 255, 255));
	        tv.setShadowLayer((float) 0.1, 0, -1, Color.argb(220, 0, 0, 0));
	        addView(iv);
	        addView(tv);	        
	    }
	    @Override
	    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
	        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
	        int parentWidth = MeasureSpec.getSize(widthMeasureSpec);	       
	        this.setMinimumWidth(parentWidth / count);
	    }
	}

